
package com.epam.android.training.app.activities;

import com.epam.android.training.app.R;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

/**
 * About activity - shows developer name and some other info. When click on
 * phone - initiate a call When click on email - opens email client
 * 
 * @author Natallia_Kukharchyk
 */
public class AboutActivity extends ActivityWithMenu {

  private TextView textView;

  private TextView phoneNumber;

  private TextView email;

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about);

    textView = (TextView) findViewById(R.id.about_title);
    textView.setText(Html.fromHtml("<strong><u>" + getString(R.string.about_title) + "</u></strong><br/><b><i>"
        + getString(R.string.about_name) + "<br/>" + getString(R.string.about_position) + "</i></b>"));

    phoneNumber = (TextView) findViewById(R.id.about_phone);
    phoneNumber.setText(R.string.about_phone);

    email = (TextView) findViewById(R.id.about_email);
    email.setText(R.string.about_email);

  }

  public void onPhoneClick(View view) {
    Intent i = new Intent(Intent.ACTION_CALL);
    i.setData(Uri.parse("tel:" + phoneNumber.getText()));
    startActivity(i);
  }

  public void onEmailClick(View view) {
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("plain/text");

    i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {
      email.getText().toString()
    });

    startActivity(Intent.createChooser(i, getText(R.string.about_send_mail)));
  }

}
